package edu.nctu.csie.jichang.database.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 日期
 * @author Jichang
 */
public class DateUtil {

	private static DateFormat FORMAT_SIMPLE = new SimpleDateFormat("yyyy-MM-dd");
	private static DateFormat FORMAT_FULL   = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
	
	public static Date getDate(){
		return new Date();
	}

	public static String getSimpleDate(){
		return getSimpleDate(getDate());
	}
	public static String getSimpleDate(Date pDate){
		if(pDate == null){
			return StringUtil.EMPTY;
		}
		return FORMAT_SIMPLE.format(pDate);
	}
	public static Date getSimpleDate(String pStrDate) throws Exception{
		return FORMAT_SIMPLE.parse(pStrDate);
	}
	
	public static String getFullDate(){
		return getFullDate(getDate());
	}
	public static String getFullDate(Date pDate){
		if(pDate == null){
			return StringUtil.EMPTY;
		}
		return FORMAT_FULL.format(pDate);
	}
	public static Date getFullDate(String pStrDate) throws Exception{
		return FORMAT_FULL.parse(pStrDate);
	}
}